﻿using B.S.DataBase.MyProject.Domain;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure.Interface;
using B.S.DataBase.MyRead.API.Appicant.CommandHandler.RoleMenu;
using MediatR;

namespace B.S.DataBase.MyRead.API.Appicant.Command.RoleMenu
{
    public class MenuNameQueryCommandHandler : IRequestHandler<MenuNameQueryCommand, APIResult<List<Menu>>>
    {
        private readonly IBaseRepository<Menu> mRepo;

        public MenuNameQueryCommandHandler(IBaseRepository<Menu>mRepo)
        {
            this.mRepo = mRepo;
        }



        public async Task<APIResult<List<Menu>>> Handle(MenuNameQueryCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<Menu>> result = new APIResult<List<Menu>>();
            result.Code = APIEnum.查询成功;
            result.Msg = APIEnum.查询成功.ToString();
            var list = mRepo.GetAll().Result;
            result.data = list.ToList();
            return await Task.FromResult(result);




        }



    }
}
